#include <QThread>
#include <QEventLoop>
#include <QTimer>
#include <QFile>
#include <QCoreApplication>
#include <QDir>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QJsonDocument>
#include "testRpcServer.h"

TestRpcServer::TestRpcServer()
{
}

void TestRpcServer::startServer()
{
    m_server.startServer(8080);
}

int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);
    TestRpcServer rpc;
    rpc.startServer();

    QUrl url("http://127.0.0.1:8080");

    QJsonObject obj;
    obj["messages"] = "hello world";
    
    QNetworkRequest req;
    req.setUrl(url);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

    QByteArray buffer = QJsonDocument(obj).toJson();

    QNetworkAccessManager manager;
    auto reply = manager.post(req, buffer);

    return app.exec();
}